//
//  YTStashAllListViewController.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/11/14.
//

#import "YTStashAllListViewController.h"
#import "YTStashForewarningListViewController.h"
#import "YTStashRecordsListViewController.h"

@interface YTStashAllListViewController ()

@property (nonatomic ,strong) UIImageView * crlimg;
@property (nonatomic ,strong) UILabel * crllab;
@property (nonatomic ,strong) UIImageView * yjimg;
@property (nonatomic ,strong) UILabel * yjlab;
///记录
@property (nonatomic ,strong) YTStashRecordsListViewController * RecordsVC;
///库存
@property (nonatomic ,strong) YTStashForewarningListViewController * ForewarningVC;


@end

@implementation YTStashAllListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIView * buttomview = [UIView new];
    buttomview.backgroundColor = UIColor.whiteColor;
    [self.view addSubview:buttomview];
    [buttomview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.offset(0);
        make.height.offset(KSafeAreaBottomHeight + kwt(52));
    }];
    UIView * line = [UIView new];
    line.backgroundColor = KcolorHex(@"#DFDFDF");
    [buttomview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(0.5);
    }];
    MJWeakSelf
    UIView * CRLView = [UIView new];
    CRLView.addClickBlock(^{
        [weakSelf openCRK];
    });
    [buttomview addSubview:CRLView];
    [CRLView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.width.offset(kwt(100));
        make.height.offset(kwt(52));
        make.centerX.offset(-KSCREEN_WIDTH/4);
    }];
    
    UIImageView * crlimg = kimageView(@"warehousing_record2");
    self.crlimg= crlimg;
    [CRLView addSubview:crlimg];
    [crlimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(5));
        make.width.height.offset(kwt(23));
        make.centerX.offset(0);
    }];
    UILabel * crllab = [DTKTool labelWithText:@"出入库记录" andFont:kFont(13) andTextColor:KcolorHex(@"#222222")];
    self.crllab = crllab;
    [CRLView addSubview:crllab];
    [crllab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(kwt(13));
        make.centerX.offset(0);
    }];
    
    
    UIView * yjView = [UIView new];
    yjView.addClickBlock(^{
        [weakSelf openYJ];
    });
    [buttomview addSubview:yjView];
    [yjView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.width.offset(kwt(100));
        make.height.offset(kwt(52));
        make.centerX.offset(KSCREEN_WIDTH/4);
    }];
    
    UIImageView * yjimg = kimageView(@"inventory_alert2");
    self.yjimg= yjimg;
    [yjView addSubview:yjimg];
    [yjimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kwt(5));
        make.width.height.offset(kwt(23));
        make.centerX.offset(0);
    }];
    //
    UILabel * yjlab = [DTKTool labelWithText:@"库存预警" andFont:kFont(13) andTextColor:KcolorHex(@"#222222")];
    self.yjlab = yjlab;
    [yjView addSubview:yjlab];
    [yjlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(kwt(13));
        make.centerX.offset(0);
    }];
    
    
    
    YTStashRecordsListViewController * RecordsVC = [YTStashRecordsListViewController new];
    self.RecordsVC = RecordsVC;
    [self addChildViewController:RecordsVC];
    [self.view addSubview:RecordsVC.view];
    [RecordsVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.bottom.equalTo(buttomview.mas_top);
    }];
    
    YTStashForewarningListViewController * ForewarningVC = [YTStashForewarningListViewController new];
    self.ForewarningVC = ForewarningVC;
    [self addChildViewController:ForewarningVC];
    [self.view addSubview:ForewarningVC.view];
    [ForewarningVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.bottom.equalTo(buttomview.mas_top);
    }];
    
    if(self.isYJ){
        [self openYJ];
    } else {
        [self openCRK];
    }
}
- (void)openCRK{
    self.yjimg.image = [UIImage imageNamed:@"inventory_alert2"];
    self.yjlab.textColor = KcolorHex(@"#222222");
    self.yjlab.font = kFont(13);
    self.RecordsVC.view.hidden = NO;

    self.crlimg.image = [UIImage imageNamed:@"warehousing_record1"];
    self.crllab.textColor = KcolorHex(@"#2C72F7");
    self.crllab.font = kCFont(13);
    self.ForewarningVC.view.hidden = YES;

}

- (void)openYJ{
    self.yjimg.image = [UIImage imageNamed:@"inventory_alert1"];
    self.yjlab.textColor = KcolorHex(@"#2C72F7");
    self.yjlab.font = kCFont(13);
    self.RecordsVC.view.hidden = YES;

    self.crlimg.image = [UIImage imageNamed:@"warehousing_record2"];
    self.crllab.textColor = KcolorHex(@"#222222");
    self.crllab.font = kFont(13);
    self.ForewarningVC.view.hidden = NO;

}



@end
